package com.boot.utils;

import com.github.benmanes.caffeine.cache.AsyncLoadingCache;
import com.github.benmanes.caffeine.cache.Caffeine;

import java.util.Objects;
import java.util.concurrent.TimeUnit;

public class CaffeineTest {


    public static void main(String[] args) throws InterruptedException {
        Integer a = 10000;
        Integer b = new Integer(10000);
        boolean equals = Objects.equals(a, b);
        AsyncLoadingCache<String, Integer> cache = Caffeine.newBuilder()
                .maximumSize(1)
                .expireAfterWrite(10, TimeUnit.SECONDS)
                // 你可以选择: 去异步的封装一段同步操作来生成缓存元素
                .buildAsync(key -> {
                    System.out.println("load.......");
                    return 1;
                });
        Thread.sleep(60 * 1000);
    }
}
